package org.java.web;

import com.alibaba.fastjson.JSON;
import org.java.dao.ArtRecommendsDao;
import org.java.dao.DaoImpl.RecommendsDaoImpl;
import org.java.entity.Recommends;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet( "/recommends")
public class RecommendsServlet extends BaseServlet {
    private ArtRecommendsDao dao = new RecommendsDaoImpl();

    protected void rec(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Recommends> list = dao.getRecommendsList();
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        String json = JSON.toJSONString(list);
        out.write(json);
        out.flush();
        out.close();
    }
}
